def solve(s, numRows):
    if numRows == 1:
        return s
    res = ["" for i in range(numRows)]
    i = 0
    flag = -1
    for c in s:
        res[i]+=c
        if i == 0 or i == numRows - 1:
            flag = -flag
        i += flag

    return "".join(res)


if __name__ == "__main__":
    s = "PAYPALISHIRING"
    numRows = 3
    print(solve(s, numRows))
